/******************************************
@Description:订单支付成功-风控数据统计
交换机=pay.paysuc
@Time : 2020/11/16 16:45
@Author :lixiaojun

*******************************************/
package main

import (
	"context"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	"git.900sui.cn/kc/rpcinterface/client/risk"
	"github.com/streadway/amqp"
)

func main() {
	rpcRisk:=new(risk.BusBasicMonth).Init()
	defer rpcRisk.Close()

	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("risk.log.riskStatisticsOrderPaySuc"))

	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("risk.queue.riskStatisticsOrderPaySuc"), func(msg amqp.Delivery) {
		orderSn := string(msg.Body)
		reply := false
		if err:=rpcRisk.RiskStatisticsOrderPaySuc(context.Background(),&orderSn,&reply);err!=nil{
			utils.Logerr.Printf("订单支付成功后，risk风控数据统计任务执行失败 orderSn:%s , err: %s",orderSn, err.Error())
		}
	})

	if err != nil {
		utils.Logerr.Printf("支付成功后，risk风控数据统计任务执行错误, err: %s", err.Error())
	}
}

